package com.authine.cloudpivot.web.api.secondopen.utils;

//import org.apache.axis.client.Call;
//import org.apache.axis.client.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.xml.namespace.QName;
//import javax.xml.rpc.ParameterMode;
//import javax.xml.rpc.ServiceException;
//import javax.xml.rpc.encoding.XMLType;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;

/**
 * @version 1.0
 * @createAuthor LongChangyou
 * @projectName huayuan
 * @packageName com.h3bpm.huayuan.common.utils
 * @fileName WebServiceUtil
 * @description //TODO webService接口调用工具类
 * @createTime 2020-02-12 19:04
 * @updateTime 2020-02-12 19:04
 * @updateAuthor LongChangyou
 **/
@Component
public class WebServiceUtil {

    private static  Logger logger = LoggerFactory.getLogger(WebServiceUtil.class);

    public static String send_url = "http://192.168.0.133:8080";
    //public static String send_url = "http://ehr.hy-online.com";

    //public final static String RECORD_FROM_WEB = "http://bpm.hy-online.com/";
    public final static String RECORD_FROM_WEB = "http://bpmtest.hy-online.com:8082/";

//    /**
//      * @author LongChangyou
//      * @createTime 2020-02-12 22:54
//      * @updateTime 2020-02-12 22:54
//      * @updateAuthor LongChangyou   http://192.168.31.250:9080/service/XChangeServlet?account=02&groupcode=G
//      * @description //TODO 根据methodName接口方法名调用宏景的webService接口,获取响应的结果
//      * @methodName getService
//      * @param methodName 方法名
//      * @param data 参数字符串集合
//      * @return java.lang.String 响应的结果
//      **/
//    public static String getService(String methodName,String data) throws ServiceException, MalformedURLException, RemoteException {
//        logger.info("methodName: "+methodName + ", data: "+ data);
//        Service service = new Service();
//        Call call = (Call) service.createCall();
//        URL endpoint = new URL(send_url+"/services/ProcessService");
//        call.setTargetEndpointAddress(endpoint);
//        call.setOperation(new QName(RECORD_FROM_WEB), methodName);
//        call.addParameter(new QName("data"), XMLType.SOAP_STRING,ParameterMode.IN);
//        call.setReturnType(XMLType.SOAP_STRING);
//        logger.info("call: "+call.toString());
//        String ret = (String)call.invoke(new Object[]{data});
//        logger.info("webservice return : " + ret);
//        ret = ret.replaceAll("'","\"");
//        return ret;
//    }
//
//
//    public static String getServiceWithServiceName(String serviceName,String methodName,String data) throws ServiceException, MalformedURLException, RemoteException {
//        logger.info("methodName: "+methodName + ", data: "+ data);
//        Service service = new Service();
//        Call call = (Call) service.createCall();
//        URL endpoint = new URL(send_url+serviceName);
//        call.setTargetEndpointAddress(endpoint);
//        call.setOperation(new QName(RECORD_FROM_WEB), methodName);
//        call.addParameter(new QName("parameters"), XMLType.SOAP_STRING,ParameterMode.IN);
//        call.setReturnType(XMLType.SOAP_STRING);
//        logger.info("call: "+call.toString());
//        String ret = (String)call.invoke(new Object[]{data});
//        logger.info("webservice return : " + ret);
//        ret = ret.replaceAll("'","\"");
//        return ret;
//    }

}
